package java_option.audio_a012.javafx;

import java.io.File;

import java_option.audio_a012.audio.AudioPlay;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.stage.FileChooser;

/**
 * 
 * @author java_option
 * @date 2020-10-31
 */
public class AudioPlayController {

	private AudioPlay audioPlay;
	private File currentVideoFile;

	public void initialize() {
		audioPlay = new AudioPlay("d:/test/收藏/张靓颖-千百度.wav", "d:/test/敲键盘.wav");
	}

	@FXML
	public void onSelectFile() {
		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("选择文件");
		String file = "D:\\test";//
		File file1 = new File(file);
		fileChooser.setInitialDirectory(file1);
		fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("只支持wav", "*.wav"));
		this.currentVideoFile = fileChooser.showOpenDialog(null);
		if (this.currentVideoFile != null) {
			this.audioPlay.addFile(currentVideoFile.getAbsolutePath());
		}
	}

	@FXML
	public void onStart(ActionEvent event) {
		audioPlay.onStart(0, 0);
	}

	@FXML
	public void onResume(ActionEvent event) {
		audioPlay.onResume();
	}

	@FXML
	public void onPause(ActionEvent event) {
		audioPlay.onPause();
	}

	@FXML
	public void onStop(ActionEvent event) {
		audioPlay.onStop();
	}

}
